package cn.tedu.yy.controller;

import cn.tedu.common.vo.JsonResult;
import cn.tedu.yy.pojo.dto.DemandDTO;
import cn.tedu.yy.pojo.dto.DemandQuery;
import cn.tedu.yy.pojo.vo.DemandVO;
import cn.tedu.yy.service.ReservationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("ry/yy")
@Api(tags = "预约服务")
public class YyController {
    @Autowired(required=true)
    ReservationService reservationService;
    @ApiOperation(value = "保存预约信息")
    @PostMapping("save")
    public JsonResult saveyy(DemandDTO demandDTO) {
        log.debug("保存预约信息：demandDTO:{}", demandDTO);
        reservationService.saveyy(demandDTO);
        return JsonResult.ok();
    }
    @ApiOperation(value = "查询预约信息")
    @GetMapping("select")
    public JsonResult selectyy(DemandQuery demandQuery) {
        log.debug("查询预约信息：demandQuery:{}", demandQuery);
        List<DemandVO> list=reservationService.selectyy(demandQuery);
        return JsonResult.ok(list);
    }
    @ApiOperation(value = "删除预约信息")
    @PostMapping("delete")
    public JsonResult deleteyy(Integer userId) {
        log.debug("删除预约信息：userId:{}", userId);
        reservationService.deleteyy(userId);
        return JsonResult.ok();
    }
 }
